- name: Docker_install
  hosts: elk
  become: yes
  gather_facts: yes
  vars:
    

  tasks:
  
   - name: Install 
     apt:
         name:
          - python3-pip
          - apt-transport-https
          - ca-certificates
          - curl
          - gnupg-agent
          - software-properties-common
         update_cache: yes
   
  
   
   - name: add apt-key
     apt_key:
          url: https://download.docker.com/linux/debian/gpg 
          state: present

   - name: add docker repository
     ansible.builtin.apt_repository:
          repo: deb [arch=amd64] https://download.docker.com/linux/debian   bullseye stable
          state: present
          

   - name: install docker
     apt:
        name:
          - docker-ce
          - docker-ce-cli
          - containerd.io
          - docker-buildx-plugin
          - docker-compose-plugin
          - docker-compose
        update_cache: yes
     notify: 
       - Start and Enable docker
      
   - name: Add the current user to the docker group
     user: 
       name: tandem
       group: docker
       append: yes

   - name: copy config 
     copy:
       src: /home/tandem/Graduate-work/ansible/playbooks/docker.config.yml
       dest: /etc/docker/daemond.json
       owner: tandem
       group: docker
       mode: 0744

  handlers:
    - name: Start and Enable docker
      service: 
       name: docker
       state: started
       enabled: yes


